package com.zengqingfa.designpattern.behavior.iterator;

/**
 * @author zengqingfa
 * @className ConcreAggregate
 * @description 容器的实现
 * @create 2021/8/25 21:50
 */
public class ConcreAggregate<T> implements Aggregate<T> {

    private T[] ele = (T[]) new Object[5];
    private int position = 0;


    @Override
    public void add(T t) {
        ele[position++] = t;
    }

    @Override
    public Iterator<T> iterator() {
        return new ConcreteIterator<T>(ele);
    }

}